package config

import "commonUtils/utils"

// Web web服务器设置
type Web struct {
	Host            string   `json:"host"`
	Addr            string   `json:"addr"`
	HTTPSCertFile   string   `json:"https_cert_file"`
	HTTPSKeyFile    string   `json:"https_key_file"`
	TempPath        string   `json:"temp_path"`
	BaseTempPath    string   `json:"base_temp_path"`
	IndexFiles      []string `json:"index_files"`
	StaticURL       string   `json:"static_url"`
	StaticFolder    string   `json:"static_folder"`
	UploadPath      string   `json:"upload_path"`
	CasbinModelPath string   `json:"casbin_model_path"`
	AESKey          string   `json:"aes_key"`

	MaxLoginFailCount int                 `json:"max_login_fail_count"`
	Captcha           utils.CaptchaConfig `json:"captcha"`
}

var webConf *Web

func Inst() *Web {
	if nil == webConf {
		utils.Error("WEB config Is Nil!!!")
	}
	return webConf
}
func Set(conf *Web) {
	webConf = conf
}

func (c *Web) GetUploadPath() string {
	path := c.StaticFolder + c.UploadPath + "/"
	return path
}

func (c *Web) GetUploadUrl() string {
	url := c.StaticURL + c.UploadPath + "/"
	return url
}
